"""
@Project ：interface_platform 
@File    ：make_response_utils.py
@IDE     ：PyCharm 
@Author  ：ZSR
@Date    ：2023/3/21 0:59 
"""

import json

from backend.utils.code_utils import CodeUtil
from flask import Response


# 响应数据
def make_response(status=CodeUtil.SUCCESS, data=None, **kwargs):
    return Response(json.dumps({"status": status, "msg": CodeUtil.MSG[status], "data": data, **kwargs}),
                    mimetype="application/json")


# 用于异常返回的响应数据
def make_exception_response(status=CodeUtil.SUCCESS, msg=None, data=None):
    return json.dumps({"status": str(status), "msg": msg if msg else CodeUtil.MSG[str(status)], "data": data})
